#include<bits/stdc++.h>

using namespace std;
int a[50][50] = {
        {7, 0, 0, 0, 0},
        {3, 8, 0, 0, 0},
        {8, 1, 0, 0, 0},
        {2, 7, 4, 4, 0},
        {4, 5, 2, 6, 5},
};
int n = 5;

//maxSum��(i,j)���Ԫ�����»����ܹ��õ�����߷���
int maxSum(int i, int j) {
    if (i == n - 1) {
        return a[i][j];
    }
    int x = maxSum(i + 1, j);
    int y = maxSum(i + 1, j + 1);

    return a[i][j] + max(x, y);
}

int main() {
    cout << maxSum(0, 0);
}
